package com.itsm.user.controller;


import com.itsm.common.core.domain.R;
import com.itsm.common.user.dto.LoginDto;
import com.itsm.user.entity.JzsyRbacUser;
import com.itsm.user.service.IAuthenticationService;
import com.itsm.user.service.IUserService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "登录")
@RestController
@RequestMapping("/itsm/user/authorization")
public class LoginController {


    @Autowired
    private IUserService userService;

    @Autowired
    private IAuthenticationService authenticationService;

    @PostMapping("/login")
    public R<?> register(@RequestBody LoginDto loginDto){
        String token = authenticationService.login(loginDto);
        return token!=null && !"".equals(token) ?  R.ok(token,"登录成功!") : R.fail();
    }
}
